/* 加载组件 - HarmonyOS设计指南实现 */

@import '../base/color.less';
@import '../base/font.less';
@import '../base/window.less';

/* 加载变量 */
:root {
  --loading-spinner-size: calc(32 * var(--unit));
  --loading-spinner-size-small: calc(24 * var(--unit));
  --loading-spinner-size-large: calc(48 * var(--unit));
  --loading-spinner-color: var(--color-brand);
  --loading-text-size: var(--font-size-body-small);
  --loading-text-color: var(--color-font-secondary);
  --loading-text-gap: calc(12 * var(--unit));
  --loading-overlay-bg: rgba(255, 255, 255, 0.9);
  --loading-animation-duration: 1s;
}

/* 基础加载样式 */
.loading {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--loading-text-gap);
}

/* 加载动画 - 旋转 */
.loading-spinner {
  width: var(--loading-spinner-size);
  height: var(--loading-spinner-size);
  border: calc(3 * var(--unit)) solid rgba(10, 89, 247, 0.1);
  border-top-color: var(--loading-spinner-color);
  border-radius: 50%;
  animation: loading-spin var(--loading-animation-duration) linear infinite;
}

/* 加载动画 - 点 */
.loading-dots {
  display: inline-flex;
  gap: calc(4 * var(--unit));
  align-items: center;
  justify-content: center;
}

.loading-dot {
  width: calc(8 * var(--unit));
  height: calc(8 * var(--unit));
  border-radius: 50%;
  background-color: var(--loading-spinner-color);
  animation: loading-dot var(--loading-animation-duration) ease-in-out infinite;
  
  &:nth-child(1) {
    animation-delay: 0s;
  }
  
  &:nth-child(2) {
    animation-delay: 0.2s;
  }
  
  &:nth-child(3) {
    animation-delay: 0.4s;
  }
}

/* 加载动画 - 脉冲 */
.loading-pulse {
  width: var(--loading-spinner-size);
  height: var(--loading-spinner-size);
  border-radius: 50%;
  background-color: var(--loading-spinner-color);
  animation: loading-pulse var(--loading-animation-duration) ease-in-out infinite;
}

/* 加载文本 */
.loading-text {
  font-size: var(--loading-text-size);
  color: var(--loading-text-color);
  margin: 0;
}

/* 加载尺寸 */
.loading-small,
.loading.small {
  .loading-spinner {
    width: var(--loading-spinner-size-small);
    height: var(--loading-spinner-size-small);
    border-width: calc(2 * var(--unit));
  }
  
  .loading-dot {
    width: calc(6 * var(--unit));
    height: calc(6 * var(--unit));
  }
  
  .loading-pulse {
    width: var(--loading-spinner-size-small);
    height: var(--loading-spinner-size-small);
  }
  
  .loading-text {
    font-size: var(--font-size-caption-medium);
  }
}

.loading-large,
.loading.large {
  .loading-spinner {
    width: var(--loading-spinner-size-large);
    height: var(--loading-spinner-size-large);
    border-width: calc(4 * var(--unit));
  }
  
  .loading-dot {
    width: calc(10 * var(--unit));
    height: calc(10 * var(--unit));
  }
  
  .loading-pulse {
    width: var(--loading-spinner-size-large);
    height: var(--loading-spinner-size-large);
  }
  
  .loading-text {
    font-size: var(--font-size-body-medium);
  }
}

/* 加载覆盖层 */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--loading-overlay-bg);
  z-index: 1000;
  border-radius: inherit;
}

/* 全屏加载 */
.loading-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--loading-overlay-bg);
  z-index: 9999;
}

/* 加载动画定义 */
@keyframes loading-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@keyframes loading-dot {
  0%, 80%, 100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes loading-pulse {
  0%, 100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  50% {
    transform: scale(1);
    opacity: 1;
  }
}

/* 加载颜色变体 */
.loading-success,
.loading.success {
  --loading-spinner-color: var(--color-confirm);
}

.loading-warning,
.loading.warning {
  --loading-spinner-color: var(--color-alert);
}

.loading-danger,
.loading.danger {
  --loading-spinner-color: var(--color-waring);
}

/* 深色模式适配 */
@media (prefers-color-scheme: dark) {
  .loading-overlay,
  .loading-fullscreen {
    --loading-overlay-bg: rgba(0, 0, 0, 0.8);
  }
}

